package cn.dnui_wnx725.dnuifood_16110100725.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * A simple {@link Fragment} subclass.
 */
public abstract class BaseFragment extends Fragment {
    protected int layout_file=0;
    View view = null;
    abstract void initView();
    abstract void  initEvent();
    abstract void initData();


    public int getLayout_file() {
        return layout_file;
    }

    public void setLayout_file(int layout_file) {
        this.layout_file = layout_file;
    }

    public BaseFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view=inflater.inflate(getLayout_file(),container,false);
        initView();
        initEvent();
        initData();
        return  view;
    }
/*    public String getUser_name(){
        SharedPreferences sp;
        sp =getActivity().getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("username","");
    }
    public String getUser_pw(){
        SharedPreferences sp;
        sp = getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("userpass","");
    }
    public Boolean getUser_remember(){
        SharedPreferences sp;
        sp = getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getBoolean("isChecked",false);
    }*/
    public String getUserID() {
        SharedPreferences sp;
        sp = getActivity().getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("userid", "");
    }
}

